package com.survey.demo.ui.fragment;

import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.survey.demo.R;
import com.survey.demo.aop.SingleClick;
import com.survey.demo.app.TitleBarFragment;
import com.survey.demo.http.glide.GlideApp;
import com.survey.demo.ui.activity.AddressListActivity;
import com.survey.demo.ui.activity.CouponActivity;
import com.survey.demo.ui.activity.HomeActivity;
import com.survey.demo.ui.activity.MySendActivity;
import com.survey.demo.ui.activity.PersonInfoActivity;
import com.survey.demo.ui.activity.SettingActivity;
import com.survey.demo.ui.activity.ShopCarActivity;
import com.survey.demo.ui.activity.StaffManageActivity;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;

/**
 *    author : Android 轮子哥
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/10/18
 *    desc   : 我的 Fragment
 */
public final class MeFragment extends TitleBarFragment<HomeActivity> {
    private RecyclerView recycler;
    private ImageView headerIv;
    public static MeFragment newInstance() {
        return new MeFragment();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.me_fragment;
    }

    @Override
    protected void initView() {
        String[] kinds = getResources().getStringArray(R.array.my_kind);
        recycler= findViewById(R.id.rv_center);
        recycler.setLayoutManager(new GridLayoutManager(getActivity(),5));
        BaseQuickAdapter adapter =new BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_re_center_top, Arrays.asList(kinds)) {
            @Override
            protected void convert(@NotNull BaseViewHolder baseViewHolder,String bean) {
                baseViewHolder.setText(R.id.tv_menu_title_home,bean);
            }
        };
        recycler.setAdapter(adapter);
        headerIv = findViewById(R.id.iv_header_icon);
        GlideApp.with(this)
                .load(R.drawable.example_bg)
                .transform(new MultiTransformation<>(new CenterCrop(), new CircleCrop()))
                .into(headerIv);
        setOnClickListener(R.id.iv_header_icon,R.id.my_collect,R.id.my_car,R.id.my_manager,R.id.my_send,R.id.my_addr,R.id.my_coupon,R.id.my_our,R.id.my_setting);
    }

    @Override
    protected void initData() {

    }

    @SingleClick
    @Override
    public void onClick(View view) {
          switch (view.getId()){
              case R.id.iv_header_icon:
                  startActivity(PersonInfoActivity.class);
                  break;
              case R.id.my_collect:

                  break;
              case R.id.my_car:
                  startActivity(ShopCarActivity.class);
                  break;
              case R.id.my_manager:
                  startActivity(StaffManageActivity.class);
                  break;
              case R.id.my_send:
                  startActivity(MySendActivity.class);
                  break;
              case R.id.my_addr:
                  startActivity(AddressListActivity.class);
                  break;
              case R.id.my_coupon:
                  startActivity(CouponActivity.class);
                  break;
              case R.id.my_our:

                  break;
              case R.id.my_setting:
                  startActivity(SettingActivity.class);
                  break;
          }
    }

    @Override
    public boolean isStatusBarEnabled() {
        // 使用沉浸式状态栏
        return !super.isStatusBarEnabled();
    }
}